#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	int i;
	int ans;
	int a[10001][4];
	for(i=1;i<=n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2]>>a[i][3];
		a[i][2]+=a[i][0];
		a[i][3]+=a[i][1];
	};
	int x,y;
	cin>>x>>y;
	for(i=n;i>0;i--){
		if(x>=a[i][0]&&x<=a[i][2]&&y>=a[i][1]&&y<=a[i][3]) {
			cout<<i;
			return 0;
		}
	};
	if(i==0) cout<<"-1\n";
	return 0;
}
